package com.kxf.androidtestdemo.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.Button;

import androidx.annotation.RequiresApi;

/**
 * @ProjectName: AndroidTestDemo
 * @Package: com.kxf.androidtestdemo.view
 * @ClassName: MyBtn
 * @Description: java类作用描述
 * @Author: kuangxuefeng
 * @qq: 1024883177
 * @CreateDate: 2020/6/28 9:56
 */
@SuppressLint("AppCompatCustomView")
public class MyBtn extends Button {
    public MyBtn(Context context) {
        super(context);
        setClickable(true);
    }

    public MyBtn(Context context, AttributeSet attrs) {
        super(context, attrs);
        setClickable(true);
    }

    public MyBtn(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setClickable(true);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public MyBtn(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        setClickable(true);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.d("MyBtn", "=====>>>onTouchEvent" + " isClickable=" + isClickable() + "  event=" + event);
        super.onTouchEvent(event);
        return false;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        Log.d("MyBtn", "=====>>>dispatchTouchEvent" + "  event=" + event);
        return super.dispatchTouchEvent(event);
//        return false;
    }

}
